<script>
  import { setContext } from "svelte";

  let childRefs = [];
  setContext("childRefs", childRefs);
  let { children } = $props();

  function getChildRefs() {
    console.log(childRefs);
  }
</script>

<div class="form">
  {@render children()}
</div>
<button onclick={getChildRefs}>获取子组件引用</button>

<style>
  .form {
    padding: 5px;
  }
</style>
